﻿using BaseUi.Device;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BaseUi
{
    /// <summary>
    /// ShieldBox2View.xaml 的交互逻辑
    /// </summary>
    public partial class ShieldBox2View : UserControl
    {
        public ShieldBox2View()
        {
            InitializeComponent();
        }
        public CeShiBan DeviceData2
        {
            get { return (CeShiBan)GetValue(DeviceDataProperty); }
            set { SetValue(DeviceDataProperty, value); }
        }

        public static readonly DependencyProperty DeviceDataProperty =
            DependencyProperty.Register("DeviceData2", typeof(CeShiBan), typeof(ShieldBox2View), new PropertyMetadata(null));
        private void Frequencyck(object sender, RoutedEventArgs e)
        {

            try
            {
                var aaa = DeviceData2.ReadFrequencycheck();
                if (aaa.IsSucceed)
                {
                    textBoxInfo.AppendText($"通信成功\r\n");
                    textBoxInfo.AppendText($"频率" + aaa.Value + "\r\n");
                }
                else
                {
                    textBoxInfo.AppendText($"失败：{aaa.Err}\r\n");
                }
            }
            catch (Exception ex)
            {
                textBoxInfo.AppendText($"错误：{ex.Message}\r\n");
            }
        }
        private void Currentck(object sender, RoutedEventArgs e)
        {

            try
            {
                var aaa = DeviceData2.ReadCurrentcheck();
                if (aaa.IsSucceed)
                {
                    textBoxInfo.AppendText($"通信成功\r\n");
                    textBoxInfo.AppendText($"电流值：" + aaa.Value + "\r\n");
                }
                else
                {
                    textBoxInfo.AppendText($"失败：{aaa.Err}\r\n");
                }
            }
            catch (Exception ex)
            {
                textBoxInfo.AppendText($"错误：{ex.Message}\r\n");
            }
        }
    }
}
